package com.amex.uam.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.amex.uam.dao.DeptDao;
import com.amex.uam.model.Message;
import com.amex.uam.model.USER_DEPT;
import com.amex.uam.service.DeptService;

@Repository("deptService")
public class DeptServiceImpl implements DeptService {

	private DeptDao deptDao;
	@Resource
	public void setDeptDao(DeptDao deptDao) {
		this.deptDao = deptDao;
	}
	
	@Override
	public Message addDepartment(USER_DEPT dept) {
		throw new RuntimeException(this.getClass().getSimpleName() + ".addDepartment not implemented");
	}

	@Override
	public Message deleteDepartment(String deptId) {
		throw new RuntimeException(this.getClass().getSimpleName() + ".deleteDepartment not implemented");
	}

	@Override
	public Message updateDepartment(USER_DEPT dept) {
		if (dept == null || dept.getDEPT_ID() == null || dept.getDEPT_ID().equals("")
				|| dept.getDEPT_NM() == null || dept.getDEPT_NM().equals("")) {
			return new Message(Message.ERROR_PARAM);
		}
		boolean success =  deptDao.updateDepartment(dept);
		return success ? new Message(Message.OK) : new Message(Message.ERROR);
	}

	@Override
	public Message getDepartment(String deptId) {
		throw new RuntimeException(this.getClass().getSimpleName() + ".getDepartment not implemented");
	}

}
